﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Infrastructure.DataTypes;
using Infrastructure;

namespace Algorithms
{   
    /// <summary>
    /// Random rating prediction, based on most frequent users`s vote
    /// </summary>
    public class RandomRatingPredictor<RatingType> : PredictionAlgorithm<RatingType> where RatingType: ICountable, new()
    {
        public override double PredictRating(Infrastructure.User<RatingType> user, Infrastructure.Item<RatingType> item)
        {
            
            Random random = new Random();
            int selectedItemIndex = random.Next(user.Votes.Count-1);
            return user.Votes[user.Votes.Keys.ElementAt(selectedItemIndex)];
        }

        public override string Name
        {
            get { return "Random"; }
        }
    }
}
